﻿package 
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author DMarchessault
	 */
	public class Player extends MovieClip 
	{
		private var _leftDown:Boolean = false;
		private var _rightDown:Boolean = false;
		private var _upDown:Boolean = false;
		private var _downDown:Boolean = false;
		private var camera:MovieClip;
		//private var xValue:Number, yValue:Number;
		public function Player():void
		{
			//camera = cam;
			//this.addEventListener(Event.ENTER_FRAME, Update);
		}
		public function Update():void 
		{
			CheckMovement();
			RotatePlayer();
		}
		
		private function RotatePlayer():void
		{
			var xValue = (stage.mouseX - this.x);
			var yValue = (stage.mouseY - this.y) * -1;
			var angle = (Math.atan(yValue / xValue)) / (Math.PI / 180);
			if (xValue < 0) { angle += 180; }
			this.rotation = (angle * -1) + 90;
			//trace(angle);
		}
		private function CheckMovement():void
		{
			if (_leftDown) { this.x -= 3; }
			if (_rightDown) { this.x += 3; }
			if (_upDown) { this.y -= 3; }
			if (_downDown) { this.y += 3; }
		}

		
		public function getRightDown():Boolean { return _rightDown; }
		public function setRightDown(value:Boolean):void  { _rightDown = value; }
		
		public function getUpDown():Boolean { return _upDown; }
		public function setUpDown(value:Boolean):void  { _upDown = value; }
		
		public function getDownDown():Boolean { return _downDown; }
		public function setDownDown(value:Boolean):void  {	_downDown = value; }
		
		public function getLeftDown():Boolean { return _leftDown; }
		public function setLeftDown(value:Boolean):void  {	_leftDown = value; }

		
	}
	
	
}